/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Entity;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author erico
 */
@Entity
@Table(name = "Waypoint")
@NamedQueries({
        @NamedQuery(name = "Waypoint.findByClosestLatLng", query = "SELECT w FROM Waypoint w WHERE w.longitude = :long AND w.latitude = :lat"),
        @NamedQuery(name = "Waypoint.findAll", query = "SELECT w FROM Waypoint w"),
        @NamedQuery(name = "Waypoint.findByWaypointid", query = "SELECT w FROM Waypoint w WHERE w.waypointid = :waypointid"),
        @NamedQuery(name = "Waypoint.findByName", query = "SELECT w FROM Waypoint w WHERE w.name = :name"),
        @NamedQuery(name = "Waypoint.findByLatitude", query = "SELECT w FROM Waypoint w WHERE w.latitude = :latitude"),
        @NamedQuery(name = "Waypoint.findByLongitude", query = "SELECT w FROM Waypoint w WHERE w.longitude = :longitude")}
)
public class Waypoint implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "waypointid")
    private Integer waypointid;
    @Basic(optional = false)
    @Column(name = "name")
    private String name;
    @Basic(optional = false)
    @Column(name = "latitude")
    private double latitude;
    @Basic(optional = false)
    @Column(name = "longitude")
    private double longitude;
    @Lob
    @Column(name = "info")
    private String info;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "waypoint1")
    private Collection<Transportation> transportationCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "waypoint2")
    private Collection<Transportation> transportationCollection1;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "waypoint1")
    private Collection<GameLevel> gameLevelCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "waypoint2")
    private Collection<GameLevel> gameLevelCollection1;

    public Waypoint() {
    }

    public Waypoint(Integer waypointid) {
        this.waypointid = waypointid;
    }

    public Waypoint(Integer waypointid, String name, double latitude, double longitude) {
        this.waypointid = waypointid;
        this.name = name;
        this.latitude = latitude;
        this.longitude = longitude;
    }

    public Integer getWaypointid() {
        return waypointid;
    }

    public void setWaypointid(Integer waypointid) {
        this.waypointid = waypointid;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public double getLatitude() {
        return latitude;
    }

    public void setLatitude(double latitude) {
        this.latitude = latitude;
    }

    public double getLongitude() {
        return longitude;
    }

    public void setLongitude(double longitude) {
        this.longitude = longitude;
    }

    public String getInfo() {
        return info;
    }

    public void setInfo(String info) {
        this.info = info;
    }

    public Collection<Transportation> getTransportationCollection() {
        return transportationCollection;
    }

    public void setTransportationCollection(Collection<Transportation> transportationCollection) {
        this.transportationCollection = transportationCollection;
    }

    public Collection<Transportation> getTransportationCollection1() {
        return transportationCollection1;
    }

    public void setTransportationCollection1(Collection<Transportation> transportationCollection1) {
        this.transportationCollection1 = transportationCollection1;
    }

    public Collection<GameLevel> getGameLevelCollection() {
        return gameLevelCollection;
    }

    public void setGameLevelCollection(Collection<GameLevel> gameLevelCollection) {
        this.gameLevelCollection = gameLevelCollection;
    }

    public Collection<GameLevel> getGameLevelCollection1() {
        return gameLevelCollection1;
    }

    public void setGameLevelCollection1(Collection<GameLevel> gameLevelCollection1) {
        this.gameLevelCollection1 = gameLevelCollection1;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (waypointid != null ? waypointid.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Waypoint)) {
            return false;
        }
        Waypoint other = (Waypoint) object;
        if ((this.waypointid == null && other.waypointid != null) || (this.waypointid != null && !this.waypointid.equals(other.waypointid))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Entity.Waypoint[waypointid=" + waypointid + "]";
    }
}
